/**
    @author: ChenLin
    @date: 2022/11/14 todo thrift调用服务
**/

package handler

import (
	"flamingo/flamingo_etcd"
	"flamingo/logger"
	"github.com/golang/protobuf/proto"
	. "go/XXProtocols"
)

type ThriftManager struct {
	flamingo_etcd.FlamingoThriftBaseManager
	request *XXUnitySSPkg
}

func (self *ThriftManager) Init() {
	self.SetPraseResultFunc(self.PraseResultFunc)
	self.FlamingoThriftBaseManager.Init()
}

func (self *ThriftManager) PraseResultFunc(respp proto.Message, serverName string) interface{} {
	if respp == nil {
		return nil
	}
	resp := respp.(*XXUnitySSPkg)
	var response proto.Message
	if serverName == "base_activity_limit" {
		response = &SActivityLimitProto{}
	} else if serverName == "ll_user_log" || serverName == "gp_user_log" {
		response = &SXXUserEventProto{}
	} else if serverName == "ll_smessage_center" || serverName == "lm_smessage_center" {
		response = &SLiuLiuXMessageProto{}
	} else if serverName == "ll_user_content" || serverName == "lm_user_content" {
		response = &SLiuLiuUserProto{}
	} else if serverName == "gp_user_content" {

	} else if serverName == "ll_fund" || serverName == "xxbox_fund" || serverName == "gp_fund" {
		response = &SLiuLiuFundProto{}
	} else if serverName == "ll_question_and_answer_base" {
		response = &SLiuLiuQuestionAndAnswerProto{}
	} else if serverName == "flamingo_ip_service" {
		response = &SFlamingoIPDataProto{}
	} else {
		logger.Logln(logger.ERROR, "not found servername to prase response pkg", serverName)
	}
	err := proto.Unmarshal(resp.GetBody(), response)
	if err != nil {
		return nil
	}
	return response
}
